package demo10;

import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        Studnet studnet1 =new Studnet("wentao",90);
        Studnet studnet2 =new Studnet("wentao",90);
        System.out.println(studnet1.equals(studnet2));
    }
    public static void main3(String[] args) {
        Studnet[] studnets = new Studnet[3];
        studnets[0] =new Studnet("wnetao",90);
        studnets[1] =new Studnet("lishenquan",85);
        studnets[2] =new Studnet("liaozijv",95);
        System.out.println("排序前"+Arrays.toString(studnets));
        NameComparator nameComparator =new NameComparator();
        ScoreComparator scoreComparator =new ScoreComparator();
        Arrays.sort(studnets,scoreComparator);
        System.out.println("排序后"+Arrays.toString(studnets));
    }
    //模拟冒泡排序
    public static void mySort(Comparable[] comparables){
        for (int i=0;i<comparables.length-1;i++){
            for(int j=0;j<comparables.length-1-i;j++){
                if(comparables[j].compareTo(comparables[j+1])>0){
                    Comparable tmp =comparables[j];
                    comparables[j] =comparables[j+1];
                    comparables[j+1] =tmp;
                }
            }
        }
    }
    public static void main2(String[] args) {
        Studnet[] studnets = new Studnet[5];
        studnets[0] = new Studnet("wentao",90);
        studnets[1] = new Studnet("lishenquan",90);
        studnets[2] =new Studnet("liaozijv",95);
        studnets[3] =new Studnet("chenhaiteng",85);
        studnets[4] =new Studnet("xiaozhantao",80);
        System.out.println("排序前"+ Arrays.toString(studnets));
        //Arrays.sort(studnets);
        mySort(studnets);
        System.out.println("排序后"+Arrays.toString(studnets));
    }
    public static void main1(String[] args) {
        Studnet studnet1 =new Studnet("wentao",90);
        Studnet studnet2 =new Studnet("liaozijv",80);
        System.out.println(studnet1.compareTo(studnet2));

    }
}
